<%--
  Created by IntelliJ IDEA.
  User: 13976
  Date: 2019/10/5
  Time: 19:12
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%
    String path = request.getContextPath();
    String basepath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<html>
<head>
    <title>Title</title>
    <base href="<%=basepath %>"/>
    <link rel="stylesheet" href="static/layui/css/layui.css">
</head>
<body >
<div style="margin: 10px">
    <h2>历史信息</h2>
</div>

<table id="demo" lay-filter="test"></table>
<div style="margin: 10px">
<h2>新增信息</h2>
</div>

    <form class="layui-form" id="form-user-add" method="post">


    <div class="layui-form-item">
        <label class="layui-form-label">版本号</label>
        <div class="layui-input-inline">
            <input type="text" name="versionno" value="" required lay-verify="required" placeholder="请输入下载次数" autocomplete="off" class="layui-input">
        </div>
    </div>
        <div class="layui-form-item">
            <label class="layui-form-label">版本大小</label>
            <div class="layui-input-inline">
                <input type="text" name="versionsize" value="" required lay-verify="required" placeholder="请输入下载次数" autocomplete="off" class="layui-input">
            </div>
        </div>

    <div class="layui-form-item">
        <label class="layui-form-label">发布状态</label>
        <div class="layui-input-inline">
          预发布
        </div>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">版本简介</label>
        <div class="layui-input-block">
            <textarea value="" name="versioninfo" placeholder="请输入内容" class="layui-textarea"></textarea>
        </div>
    </div>

    <div class="layui-form-item">
        <input class="layui-input" value=""  name="downloadlink" autocomplete="off" id="photo"  />
        <label class="layui-form-label">APK文件</label>
        <div class="layui-input-inline" style="width:300px">
            <button class="magicalcoder-layupload layui-btn" type="button" id="photobtn">上传文件</button>

        </div>
    </div>
        <div class="layui-form-item">

            <div class="layui-input-inline">
                <input type="hidden" value="${xin}" name="appid" id="ii" required  lay-verify="required" placeholder="请输入软件名称" autocomplete="off" class="layui-input">
            </div>
        </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo" >立即提交</button>
            <button class="layui-btn"  lay-filter="formDemo" onclick="parent.window.location.reload()">返回</button>
        </div>
    </div>


</form>
<script src="static/js/jquery.min.js"></script>
<script src="static/ruoyi/ry-ui.js"></script>
<script src="static/layui/layui.all.js"></script>
<script src="static/validate/jquery.validate.min.js"></script>
<script src="static/validate/messages_zh.min.js"></script>
<script src="static/validate/jquery.validate.extend.js"></script>

<script type="text/javascript">
    //init method one




    //多图片上传
    var id=$("#ii").val();
    layui.use('table', function() {
        var table = layui.table;


        //第一个实例
        table.render({
            elem: '#demo'
            , height: 182
            , url: 'ver/list/'+id //数据接口

            , cols: [[ //表头


                {field: 'yi', title: '软件名字', width: 200}
                , {field: 'versionno', title: '版本号', width: 100}

                , {field: 'versionsize', title: '版本大小(M)', width: 105}
                , {field: 'er', title: '发布状态', width: 100}
                , {field: 'downloadlink', title: '文件下载地址', width: 200}
                , {field: 'updatedTime', title: '最新时间', width: 200}

                /*,{field: 'grade.gname', title: '年级', templet: function(d){
                        return d.grade.gname
                    }}*/

            ]],
            parseData: function (res) { //res 即为原始返回的数据
                return {
                    "code": res.code, //解析接口状态
                    "msg": res.msg, //解析提示文本
                    "count": res.count, //解析数据长度
                    "data": res.data //解析数据列表
                };
            }
            , id: 'testReload'
            , page: true
        });




    })

    layui.use(['upload','form','laydate'], function (upload,form,laydate) {
        var $ = layui.jquery;
        upload.render({
            elem: '#photobtn'
            ,url: 'dev/upload1'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){

                });
            }
            ,done: function(res, index, upload){ //上传后的回调
                $("#photo").val(res.msg);
            }

            ,accept: 'file' //允许上传的文件类型
            ,size: 10000000 //最大允许上传的文件大小
            //,……
        })

        form.on('submit(formDemo)',function (data) {
            if($("#yi").val()=="0"||$("#er").val()=="0"||$("#san").val()=="0"||$("#ping").val()=="0"){
                layer.msg("请选择下拉列表内容")
            }
            $.post("ver/addVer",data.field,function (res) {
                console.log(res)
                layer.msg('添加成功', {
                    index:100,
                    icon: res,
                    time: 2000 //2秒关闭（如果不配置，默认是3秒）
                }, function(){
                    //刷新父窗口
                    parent.window.location.reload();
                });

            })

            return false;
        })


    });


    layui.use(['upload','form','laydate'], function (upload,form,laydate) {
        var $ = layui.jquery;
        laydate.render({
            elem: '#admissionDate' //指定元素
            ,type: 'datetime'
        });


        //多图片上传

    })
</script>

</body>
</html>
